﻿using Api.Dal;
using Api.Model;

namespace Api.Bll
{
    public class UserBLL
    {
        public int count { get; set; }
        public User? GetUser(User user)
        {
            User? ur = UserDal.GetUser(user);
            return ur;
        }
        public string InsertUser(User user)
        {
            user.id = ++count;
            return UserDal.AddUser(user);
        }
        public bool UpdateUser(User user)
        {
            return UserDal.UpdateUser(user);
        }
        public bool DeleteUser(int uid)
        {
            bool u = UserDal.RemoveUser(uid);
            if(u)
            {
                u = PostDAL.DeletePostByUserId(uid);
            }
            return u;
        }

        public bool changeIcon(int id,string path)
        {
            return UserDal.changeIcon(id,path);
        }

        public List<User> getAllUsers()
        {
            return UserDal.getAllUsers();
        }
    }
}
